Skip to content

change call_child_workflow to pass correct wf name to durabletask worker#616

Merged
berndverst merged 5 commits into
dapr:masterfrom
bkc:patch-1
Oct 31, 2023
Merged

change call_child_workflow to pass correct wf name to durabletask worker#616
berndverst merged 5 commits into
dapr:masterfrom
bkc:patch-1

Conversation

@bkc

@bkc bkc commented Oct 11, 2023

Copy link
Copy Markdown
Contributor

Description

durabletask.worker uses orchestrator.__name__ here

but when dapr_workflow_context wraps the real workflow function in wf, the correct orchestrator name is lost.

This bug results in the following exception:

durabletask.task.TaskFailedError: Sub-orchestration task #1 failed: A 'wf' orchestrator was not registered.

when called as

raw_download_result = yield ctx.call_child_workflow(
            workflow=files_com_wf.files_com_download_file_wf,
            input=path,
            instance_id=None,
        )

This proposed fix is not pretty, but it works.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #615

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

There aren't any existing tests or even any examples that use call_child_workflow, I'm sorry I do not have time to write tests or documentation at this time.

durabletask.worker uses orchestrator.__name__ at https://github.com/microsoft/durabletask-python/blob/c9990973a7cc18b2db1219d129961cede9eb3948/durabletask/worker.py#L387  

but when dapr_workflow_context wraps the real workflow function in `wf`, the correct orchestrator name is lost.

This bug results in an exception:

durabletask.task.TaskFailedError: Sub-orchestration task #1 failed: A 'wf' orchestrator was not registered.

This proposed fix is not pretty, but it works.

Signed-off-by: Brad Clements <bkc@murkworks.com>
@bkc bkc requested review from a team as code owners October 11, 2023 22:05
daprWfContext = DaprWorkflowContext(ctx)
return workflow(daprWfContext, inp)
wf.__name__ = workflow.__name__ # copy workflow name so durabletask.worker can find the orchestrator in its registry
return self.__obj.call_sub_orchestrator(wf, input=input, instance_id=instance_id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While hacky, this feels like the right fix given the current limitations of the durabletask-python library. Ideally we add a parameter to call_sub_orchestrator that allows overriding the name so that callers don't need to be aware of the internal implementation details.

@DeepanshuA thoughts?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this and you can consider a better solution in a future release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment line is too long. Please see Python style guide ;)

berndverst
berndverst previously approved these changes Oct 31, 2023
Comment thread ext/dapr-ext-workflow/dapr/ext/workflow/dapr_workflow_context.py Outdated
berndverst
berndverst previously approved these changes Oct 31, 2023
Comment thread ext/dapr-ext-workflow/dapr/ext/workflow/dapr_workflow_context.py Outdated
@berndverst berndverst merged commit 00937c6 into dapr:master Oct 31, 2023
@yaron2 yaron2 added this to the v1.14 milestone Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

call_child_workflow breaks due to orchestrator name being lost

4 participants